package oving6;

public class CreditAccount implements Account {
	
	int balance;
	int credit;
	int fees;
	
	public CreditAccount(int credit){
		fees=0;
		balance=0;
		this.credit=credit;
	}
	
	public int getFees(){
		return fees;
	}

	public int deposit(int newDepo) {
		if(newDepo>0){
			balance+=newDepo;
		}
		return balance;
	}

	public int getBalance() {
		return balance;
	}

	public int getCredit() {
		return credit;
	}

	public int withdraw(int newWithd) {
		if(newWithd<0||newWithd>balance){
			if(50+newWithd<=balance+credit&&newWithd>0){
				balance -=(newWithd+50);
				fees+=50;
				return newWithd;
			}
			return 0;
		}
		else{
			balance-=newWithd;
			return newWithd;
		}
		
	}
}
